'use strict';
	angular.module('customer.customerItemSingle', [])

	.controller('customerItemSingleCtrl'
			,['$rootScope', '$scope', 'apiService','systemService'
			  ,'BizData'
			   , f])//控制器结束
	function f($rootScope,$scope, apiService,systemService
					   , BizData
					   ) {
		
		var common = require('common');
		
		var Model = this;
		
		var userId;
		var enterpriseNo;
		var enterpriseName;
		
		
		/**
		name:bizData#onNewCreateParam
		description: <b>[回调型事件]</b>业务新增数据创建新增参数事件，可以增加和修改用户自定义的参数
		@param {object} event 
		<br/><b>结构如下：</b>
		<xmp> 
		{
			"source" : 组件的js对象,
			"param" : {justep.Request.ActionParam} 新增参数对象,
			"defaultValues" : array - 新增行的默认值数组 ，数组的长度决定新增行数，数组中的对象是列的默认值
				defaultValues格式：
					[
						{列名:默认值,...},
						{列名:默认值,...},
						...
					]
		}
		</xmp>	
		@see justep.XData#newData
		@see justep.Request.ActionParam
		*/
		Model.dataMasterNewCreateParam = function(event) {
			//event.param = {"billType": billType};
		};

		/**
		name:bizData#onBeforeNew
		description: <b>[回调型事件]</b>业务数据新增前
		@param {object} event 它的结构如下:<br/>{"source":组件的js对象,"cancel":可修改，设置为true后中断当前new动作}
		 */
		Model.dataMasterBeforeNew = function(event) {
			
		};
		/**
		 * name:bizData#onAfterNew description: <b>[回调型事件]</b>业务数据新增后
		 * 
		 * @param event
		 *            它的结构如下:<br/>{"source":组件的js对象,"id":新增的行Id}
		 */
		Model.dataMasterAfterNew = function(event){

		};

		/**
		name:bizData#onBeforeDelete
		description: <b>[回调型事件]</b>业务数据删除前
		@param {object} event 它的结构如下:<br/>
		{
			"source":组件的js对象
			,"cancel":可修改	，设置为true后中断当前delete动作
			,"deleteIDList":删除的行Id数组
		}
		*/
		Model.dataMasterBeforeDelete = function(event) {
//			alert(event.deleteIDList[0]);
		};
		
		/**
		name:bizData#onAfterDelete
		description: <b>[回调型事件]</b>业务数据删除后
		@param {object} event 
		<br/><b>结构如下：</b>
		<xmp> 
		{
			"source" : 组件的js对象,
			"deleteIDList" : 删除的行Id数组
		}
		</xmp>	
		*/
		Model.dataMasterAfterDelete = function(event) {
//			alert('删除之后！')
		};

		
		
		/**
		name:bizData#onIndexChanged
		description: <b>[回调型事件]</b>行记录变化
		@param {object} event 
		<br/><b>结构如下：</b>
		<xmp> 
		{
			"source" : 组件的js对象,
			"rowID" : 行Id,
			"rowIndex" : 行索引
		}
		</xmp>	
		*/
		Model.dataMasterIndexChanged = function(event) {
//			if(event.rowID!=null){
//				Model.dataDetail.fMasterID = event.rowID;
//	       		Model.dataDetail.refreshData();
//			}else{
//				Model.dataDetail.clearData();
//			}
		};
		
		/**
		name:bizData#onDataChanged
		description: <b>[回调型事件]</b>数据发生变化（包括新增、刷新、删除、修改引起的变化），感知从data的变化
		@param {object} event 
		<br/><b>结构如下：</b>
		<xmp> 
		{
			"source" : 组件的js对象,
			"changedSource" ：触发变化的组件的js对象，当从data触发时返回从data对象,
			"selfChanged" : 是否自身变化，false：从data触发的变化,
			"type" : 触发变化的类型，包括：new、delete、refresh、valueChanged、clear，其他参数根据触发类型不同给出不同参数，参考onAfterNew等事件参数
		}
		</xmp>	
		*/
		Model.dataMasterDataChanged = function(event) {
			
		};
		
		/**
		name:bizData#onValueChanged
		description: <b>[回调型事件]</b>数据变化
		@param {object} event 
		<br/><b>结构如下：</b>
		<xmp> 
		{
			"source" : 组件的js对象,
			"column" : 关系,
			"rowIndex" : 行索引,
			"value" : 新值,
			"originalValue" : 旧值
		}
		</xmp>	
		*/
		//输入值变化，监视input的输入，ng-change
		Model.dataMasterValueChanged = function(event) {
			//console.log('dataMasterValueChanged.event-->>',event);
			if(event.column=='discountRate'){
				var rowID = event.source.getID(event.rowIndex);
				var salePrice = event.source.getValue('salePrice',rowID);
				var discountRate = event.value;
				var custPrice = common.accMul(salePrice,discountRate);
				event.source.setValue('custPrice',custPrice,rowID);
			}
			if(event.column=='custPrice'){
				var rowID = event.source.getID(event.rowIndex);
				var salePrice = event.source.getValue('salePrice',rowID);
				var custPrice = event.value;
				var discountRate = common.accDiv(custPrice,salePrice);
				event.source.setValue('discountRate',discountRate,rowID);
			}
		};
		
		
		Model.dataMasterBeforeSave = function(event) {
			console.log('dataMasterBeforeSave-->',event);
			var isMember = event.source.getValue('isMember',event.source.getCurrentID());
			if(isMember==1){
				//是会员
				var memberNo = event.source.getValue('memberNo',event.source.getCurrentID());
				if(memberNo==null || memberNo==undefined || memberNo==''){
					event.cancel = true;
					alert('会员卡号不能为空！');
				}
			}
		};
		
		
		Model.dataMasterAfterSave = function(event) {
//			console.log('dataMasterAfterSave.event-->',event);
			//这是为了后台生成的客户编码能够刷新到前台来！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
			Model.dataMaster.refreshPageData();			
		};

		///////////////////按钮组开始///////////////////////////////////////////////////
		//新建
		Model.add = function(){
			
		     var options = {
			         index : 0,
			         defaultValues : [
			             {
			            	 state:'active'
			            	 ,status:'open'
//			            	 ,audit:'active'
			            	 ,taxType:1
			            	 ,taxTypeLabel:'1.应税内含'
			            	 ,taxRate:0
			            	 ,depositRate:1
			            	 
			            	 ,custPrice:0
			            	 ,discountRate:0
			            	 
			            	 ,orderDate: ':getCurrentDate()'
				             ,employeeNo: ':getCurrentPsmFID()'
					         ,employeeName: ':getCurrentPsmFName()'
				             ,cUsercode: ':getCurrentPersonCode()'
					         ,cUsername: ':getCurrentPersonName()'
						     ,cDatetime: ':getCurrentDateTime()'
							 ,userId: ':getCurrentPersonID()'
							 ,enterpriseNo: ':getCurrentOgnFID()'
							 ,enterpriseName: ':getCurrentOgnLongName()'
							 ,version: 0

			            }//,
//			             {itemNo:'a2',itemDescribe:'b2'}
			         ]
			     };    

			Model.dataMaster.newData(options);

			if($scope.tabpanel!='single'){
				$scope.tabpanel='single'
			}
		};
		
		//修改
		Model.edit = function(){
			/*
			/////////////////////////////////////////////////////////////
			var dataMaster = Model.dataMaster;
			var rowID = dataMaster.getCurrentID();
			var userId = dataMaster.getValue('userId',rowID);
			if(userId!=$rootScope.getCurrentPersonID()){
				systemService.dialogMsg('当前数据不是由您创建，您无权进行此操作！');
				return;
			}
			////////////////////////////////////////////////////////////////
			*/
			Model.dataMaster.editData();
			if($scope.tabpanel!='single'){
				$scope.tabpanel='single'
			}
		};
		
		//保存
		Model.save = function() {
			Model.dataMaster.saveData();
		};

		//取消保存
		Model.saveCancel = function() {
			Model.dataMaster.editCancel();
		};
		
		/*
		//不提示直接提交后台删除当前行
		var data = justp.xbl('mainData');
		var deleteConfirm = data.deleteConfirm;
		var directDeleteMode = data.directDeleteMode;
		try{
		    data.deleteConfirm = false;
		    data.directDeleteMode = true;
		    data.deleteData(data.getID());
		}finally{
		    data.deleteConfirm = deleteConfirm;
		    data.directDeleteMode = directDeleteMode;
		}
		*/
		//删除
		Model.remove = function() {
			/*
			/////////////////////////////////////////////////////////////
			var dataMaster = Model.dataMaster;
			var rowID = dataMaster.getCurrentID();
			var userId = dataMaster.getValue('userId',rowID);
			if(userId!=$rootScope.getCurrentPersonID()){
				systemService.dialogMsg('当前数据不是由您创建，您无权进行此操作！');
				return;
			}
			////////////////////////////////////////////////////////////////
			*/
			Model.dataMaster.deleteData(Model.dataMaster.getCurrentID());
			Model.dataMaster.refreshData();
		};
		
		//刷新
		Model.refresh = function() {
			Model.dataMaster.refreshData();
		};
		///////////////////按钮组结束///////////////////////////////////////////////////

		
		//打开对话框（选择交易对象）
		Model.triggerProviderNoClick = function(){
			
     		var dataMaster = Model.dataMaster;
     		var rowID = dataMaster.getCurrentID();
     		var customerNo = dataMaster.getValue('customerNo', rowID);
     		if(customerNo!=null && customerNo!=''){
         		dataMaster.setValue('storageTypeD', null, rowID);
         		dataMaster.setValue('storageTypeDLabel', null, rowID);
         		dataMaster.setValue('customerID', null, rowID);
         		dataMaster.setValue('customerNo', null, rowID);
         		dataMaster.setValue('shortName', null, rowID);
         		dataMaster.setValue('customerName', null, rowID);
         		
         		dataMaster.setValue('isMember', 0, rowID);
         		dataMaster.setValue('memberNo', null, rowID);
     			
//         		dataMaster.setValue('settleCategory', null, rowID);
//         		dataMaster.setValue('settleCategoryLabel', null, rowID);
//         		dataMaster.setValue('invoiceCategory', null, rowID);
//         		dataMaster.setValue('invoiceCategoryLabel', null, rowID);
//         		dataMaster.setValue('taxType', 0, rowID);
//         		dataMaster.setValue('taxTypeLabel', '0.应税外加', rowID);
//         		dataMaster.setValue('taxRate', 0, rowID);
//         		dataMaster.setValue('depositRate', 1, rowID);
         		
//         		dataMaster.setValue('fAddressName', null, rowID);
//         		dataMaster.setValue('fAddress', null, rowID);
//         		dataMaster.setValue('fAddressDetail', null, rowID);
//         		dataMaster.setValue('fProvince', null, rowID);
//         		dataMaster.setValue('fCity', null, rowID);
//         		dataMaster.setValue('fZone', null, rowID);
//         		dataMaster.setValue('contacts', null, rowID);
//         		dataMaster.setValue('mobilePhone', null, rowID);
//         		dataMaster.setValue('fPhone', null, rowID);
     			return;
     		}

     		var options = {};
			options.recordState = 'none';
			options.id = dataMaster.getValue('enterpriseNo',rowID);

			var modalInstance = systemService.openCustomerNoDialog(options);
			
	        //模态窗口关闭之后执行的事件
	        modalInstance.result.then(function (event) {  
	             //成功关闭窗口
	         	var returnData = event.data;
	         	//debugger;
	             try {
	             	for ( var i = 0; i < returnData.length; i++) {
//	             		console.log(returnData[i]);
	             		dataMaster.setValue('storageTypeD', returnData[i].storageTypeD, rowID);
	             		dataMaster.setValue('storageTypeDLabel', returnData[i].storageTypeDLabel, rowID);
	             		dataMaster.setValue('customerID', returnData[i].fID, rowID);
	             		dataMaster.setValue('customerNo', returnData[i].customerNo, rowID);
	             		dataMaster.setValue('shortName', returnData[i].shortName, rowID);
	             		dataMaster.setValue('customerName', returnData[i].customerName, rowID);
	             		
	             		dataMaster.setValue('isMember', returnData[i].isMember, rowID);
	             		dataMaster.setValue('memberNo', returnData[i].memberNo, rowID);
	         			
//	             		dataMaster.setValue('settleCategory', returnData[i].settleCategory, rowID);
//	             		dataMaster.setValue('settleCategoryLabel', returnData[i].settleCategoryLabel, rowID);
//	             		dataMaster.setValue('invoiceCategory', returnData[i].invoiceCategory, rowID);
//	             		dataMaster.setValue('invoiceCategoryLabel', returnData[i].invoiceCategoryLabel, rowID);
//	             		dataMaster.setValue('taxType', returnData[i].taxType, rowID);
//	             		dataMaster.setValue('taxTypeLabel', returnData[i].taxTypeLabel, rowID);
//	             		dataMaster.setValue('taxRate', returnData[i].taxRate, rowID);
//	             		dataMaster.setValue('depositRate', returnData[i].depositRate, rowID);
	         			
//	             		dataMaster.setValue('fAddressName', returnData[i].fAddressName, rowID);
//	             		dataMaster.setValue('fAddress', returnData[i].fAddress, rowID);
//	             		dataMaster.setValue('fAddressDetail', returnData[i].fAddressDetail, rowID);
//	             		dataMaster.setValue('fProvince', returnData[i].fProvince, rowID);
//	             		dataMaster.setValue('fCity', returnData[i].fCity, rowID);
//	             		dataMaster.setValue('fZone', returnData[i].fZone, rowID);
//	             		dataMaster.setValue('contacts', returnData[i].contacts, rowID);
//	             		dataMaster.setValue('mobilePhone', returnData[i].mobilePhone, rowID);
//	             		dataMaster.setValue('fPhone', returnData[i].fPhone, rowID);
	                 }
	             } finally {
	             	return;
	             }

	        }, function (reason) {  
	            console.info('Modal dismissed at: ' + new Date());  
	        });  
			
		};
		

		//打开对话框（选择物料）
		Model.triggerItemNoClick = function(){
     		var dataMaster = Model.dataMaster;
     		var rowID = dataMaster.getCurrentID();
			var options = {};
			
			options.recordState = 'none';
			options.id = dataMaster.getValue('enterpriseNo',rowID);
//			options.from = 'BOM';
			var modalInstance = systemService.openItemNoDialog(options);
			
	        //模态窗口关闭之后执行的事件
	        modalInstance.result.then(function (event) {  
	             //成功关闭窗口
	        	
	         	var simpleRow = event.data[0];
//	        	systemService.itemSelectSingle(simpleRow,Model.dataDetail);
			    try {
		    		//alert(returnData[i].rowid+'-->'+returnData[i].billTypeName);
					
	     			dataMaster.setValue('itemID', simpleRow.fID, rowID);
					dataMaster.setValue('itemNo', simpleRow.itemNo, rowID);
					dataMaster.setValue('itemDescribe', simpleRow.itemDescribe, rowID);
					dataMaster.setValue('itemName', simpleRow.itemName, rowID);
					dataMaster.setValue('itemProperty', simpleRow.itemProperty, rowID);
//					dataMaster.setValue('rationSize', simpleRow.rationSize, rowID);
//					dataMaster.setValue('classCode', simpleRow.classCode, rowID);
//					dataMaster.setValue('classLabel', simpleRow.classLabel, rowID);
					dataMaster.setValue('unitCode', simpleRow.unitCode, rowID);
					dataMaster.setValue('unitName', simpleRow.unitName, rowID);
					dataMaster.setValue('process', simpleRow.process, rowID);
					dataMaster.setValue('processLabel', simpleRow.processLabel, rowID);
					dataMaster.setValue('costingType', simpleRow.costingType, rowID);
					dataMaster.setValue('qualityType', simpleRow.qualityType, rowID);
					dataMaster.setValue('qualityTypeLabel', simpleRow.qualityTypeLabel, rowID);
					dataMaster.setValue('qualityPeriod', simpleRow.qualityPeriod, rowID);
					dataMaster.setValue('validDays', simpleRow.validDays, rowID);
					dataMaster.setValue('checkoutAgainDays', simpleRow.checkoutAgainDays, rowID);
					
					dataMaster.setValue('storeNo', simpleRow.storeNo, rowID);
					dataMaster.setValue('batchNo', simpleRow.batchNo, rowID);
					dataMaster.setValue('routingNo', simpleRow.routingNo, rowID);
					
         			dataMaster.setValue('saxType', simpleRow.saxType, rowID);
         			dataMaster.setValue('saxTypeLabel', simpleRow.saxTypeLabel, rowID);
         			dataMaster.setValue('saxRate', simpleRow.saxRate, rowID);

	    			dataMaster.setValue('salePrice', simpleRow.salePrice, rowID);
	    			dataMaster.setValue('custPrice', simpleRow.salePrice, rowID);
	    			
         			dataMaster.setValue('costingAmountPer', simpleRow.costingAmountPer, rowID);

		    		
			    } finally {
			    }
	        	

	        }, function (reason) {  
	            console.info('Modal dismissed at: ' + new Date());  
	        });  
			
		};

		

		//打开对话框（选择经办人）
		Model.triggerOrgNoClick = function(){
			
     		var dataMaster = Model.dataMaster;
     		var rowID = dataMaster.getCurrentID();
     		var employeeNo = dataMaster.getValue('employeeNo', rowID);
     		if(employeeNo!=null && employeeNo!=''){
         		dataMaster.setValue('employeeNo', null, rowID);
         		dataMaster.setValue('employeeName', null, rowID);
     			return;
     		}
			
			
			var options = {};
			options.id = dataMaster.getValue('enterpriseNo',rowID);
			//是否显示人员
			options.psm = true;

			var modalInstance = apiService.openOrgNoDialog(options);
			
	        //模态窗口关闭之后执行的事件
	        modalInstance.result.then(function (event) {  
	             //成功关闭窗口
	         	var returnData = event.data;
	         	//debugger;
	             try {
	             	for ( var i = 0; i < returnData.length; i++) {
//	             		alert(returnData[i].sID+'-->'+returnData[i].sFName);
	             		dataMaster.setValue('employeeNo', returnData[i].sFID, rowID);
	             		dataMaster.setValue('employeeName', returnData[i].sFName, rowID);
	         			
	                 }
	             } finally {
	             	return;
	             }

	        }, function (reason) {  
	            console.info('Modal dismissed at: ' + new Date());  
	        });  
			
		};

		
		//双击事件
		Model.gridListRowDblclick = function(rowIndex,rowID){
			$scope.tabpanel = 'single';
		}
		

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		var options = {};
		options.container = Model;
		options.concept = 'CustomerItem';
		options.name = 'dataMaster';
		options.url = $rootScope.path;
		options.httpUrl = $rootScope.getServiceName();
		options.creater = '/customer/customerItem/single/create';
		options.reader = '/customer/customerItem/single/query';
		options.writer = '/customer/customerItem/single/save';
		options.deleter = '/customer/customerItem/single/delete';
		options.idColumnDefine = "fID";
		options.idColumnName = "fID";
//		options.defCols = {fID:{name:"fID",type:"String",label:""},orderDate:{name:"orderDate",type:"Date",label:""},state:{name:"state",type:"String",label:""},status:{name:"status",type:"String",label:""},customerID:{name:"customerID",type:"String",label:""},itemID:{name:"itemID",type:"String",label:""},upperShelf:{name:"upperShelf",type:"Integer",label:""},batchNo:{name:"batchNo",type:"String",label:""},fParent:{name:"fParent",type:"String",label:""},configType:{name:"configType",type:"Integer",label:""},itemNo:{name:"itemNo",type:"String",label:""},itemDescribe:{name:"itemDescribe",type:"String",label:""},itemProperty:{name:"itemProperty",type:"String",label:""},itemName:{name:"itemName",type:"String",label:""},unitName:{name:"unitName",type:"String",label:""},process:{name:"process",type:"String",label:""},processLabel:{name:"processLabel",type:"String",label:""},forSale:{name:"forSale",type:"String",label:""},forUsed:{name:"forUsed",type:"String",label:""},qualityType:{name:"qualityType",type:"Integer",label:""},qualityTypeLabel:{name:"qualityTypeLabel",type:"String",label:""},qualityPeriod:{name:"qualityPeriod",type:"Integer",label:""},validDays:{name:"validDays",type:"Integer",label:""},checkoutAgainDays:{name:"checkoutAgainDays",type:"Integer",label:""},storeNo:{name:"storeNo",type:"String",label:""},taxType:{name:"taxType",type:"Integer",label:""},taxTypeLabel:{name:"taxTypeLabel",type:"String",label:""},taxRate:{name:"taxRate",type:"Decimal",label:""},itemPrice:{name:"itemPrice",type:"Decimal",label:""},saxType:{name:"saxType",type:"Integer",label:""},saxTypeLabel:{name:"saxTypeLabel",type:"String",label:""},saxRate:{name:"saxRate",type:"Decimal",label:""},salePrice:{name:"salePrice",type:"Decimal",label:""},itemWeight:{name:"itemWeight",type:"Decimal",label:""},itemSize:{name:"itemSize",type:"String",label:""},orderWeight:{name:"orderWeight",type:"Decimal",label:""},orderSize:{name:"orderSize",type:"String",label:""},imageurl:{name:"imageurl",type:"String",label:""},images:{name:"images",type:"String",label:""},itemClassID:{name:"itemClassID",type:"String",label:""},barcode:{name:"barcode",type:"String",label:""},storageTypeD:{name:"storageTypeD",type:"String",label:""},storageTypeDLabel:{name:"storageTypeDLabel",type:"String",label:""},customerNo:{name:"customerNo",type:"String",label:""},shortName:{name:"shortName",type:"String",label:""},customerName:{name:"customerName",type:"String",label:""},isMember:{name:"isMember",type:"Integer",label:""},memberNo:{name:"memberNo",type:"String",label:""},dealDateFirst:{name:"dealDateFirst",type:"Date",label:""},dealDateLast:{name:"dealDateLast",type:"Date",label:""},custPrice:{name:"custPrice",type:"Decimal",label:""},discountRate:{name:"discountRate",type:"Decimal",label:""},predictStart:{name:"predictStart",type:"Date",label:""},predictEnd:{name:"predictEnd",type:"Date",label:""},createDatetime:{name:"createDatetime",type:"Datetime",label:""},userId:{name:"userId",type:"String",label:""},enterpriseNo:{name:"enterpriseNo",type:"String",label:""},enterpriseName:{name:"enterpriseName",type:"String",label:""},version:{name:"version",type:"long",label:""}};
		options.defCols = {fID:{name:"fID",type:"String",label:""},orderDate:{name:"orderDate",type:"Date",label:""},state:{name:"state",type:"String",label:""},status:{name:"status",type:"String",label:""},customerID:{name:"customerID",type:"String",label:""},itemID:{name:"itemID",type:"String",label:""},batchNo:{name:"batchNo",type:"String",label:""},fParent:{name:"fParent",type:"String",label:""},configType:{name:"configType",type:"Integer",label:""},itemNo:{name:"itemNo",type:"String",label:""},itemDescribe:{name:"itemDescribe",type:"String",label:""},itemProperty:{name:"itemProperty",type:"String",label:""},itemName:{name:"itemName",type:"String",label:""},unitName:{name:"unitName",type:"String",label:""},process:{name:"process",type:"String",label:""},processLabel:{name:"processLabel",type:"String",label:""},forSale:{name:"forSale",type:"String",label:""},forUsed:{name:"forUsed",type:"String",label:""},qualityType:{name:"qualityType",type:"Integer",label:""},qualityTypeLabel:{name:"qualityTypeLabel",type:"String",label:""},qualityPeriod:{name:"qualityPeriod",type:"Integer",label:""},validDays:{name:"validDays",type:"Integer",label:""},checkoutAgainDays:{name:"checkoutAgainDays",type:"Integer",label:""},storeNo:{name:"storeNo",type:"String",label:""},taxType:{name:"taxType",type:"Integer",label:""},taxTypeLabel:{name:"taxTypeLabel",type:"String",label:""},taxRate:{name:"taxRate",type:"Decimal",label:""},itemPrice:{name:"itemPrice",type:"Decimal",label:""},saxType:{name:"saxType",type:"Integer",label:""},saxTypeLabel:{name:"saxTypeLabel",type:"String",label:""},saxRate:{name:"saxRate",type:"Decimal",label:""},salePrice:{name:"salePrice",type:"Decimal",label:""},itemWeight:{name:"itemWeight",type:"Decimal",label:""},itemSize:{name:"itemSize",type:"String",label:""},orderWeight:{name:"orderWeight",type:"Decimal",label:""},orderSize:{name:"orderSize",type:"String",label:""},imageurl:{name:"imageurl",type:"String",label:""},images:{name:"images",type:"String",label:""},itemClassID:{name:"itemClassID",type:"String",label:""},barcode:{name:"barcode",type:"String",label:""},storageTypeD:{name:"storageTypeD",type:"String",label:""},storageTypeDLabel:{name:"storageTypeDLabel",type:"String",label:""},customerNo:{name:"customerNo",type:"String",label:""},shortName:{name:"shortName",type:"String",label:""},customerName:{name:"customerName",type:"String",label:""},isMember:{name:"isMember",type:"Integer",label:""},memberNo:{name:"memberNo",type:"String",label:""},dealDateFirst:{name:"dealDateFirst",type:"Date",label:""},dealDateLast:{name:"dealDateLast",type:"Date",label:""},custPrice:{name:"custPrice",type:"Decimal",label:""},predictStart:{name:"predictStart",type:"Date",label:""},predictEnd:{name:"predictEnd",type:"Date",label:""},cUsercode:{name:"cUsercode",type:"String",label:""},cUsername:{name:"cUsername",type:"String",label:""},cDatetime:{name:"cDatetime",type:"Datetime",label:""},tUsercode:{name:"tUsercode",type:"String",label:""},tUsername:{name:"tUsername",type:"String",label:""},tDatetime:{name:"tDatetime",type:"Datetime",label:""},eUsercode:{name:"eUsercode",type:"String",label:""},eUsername:{name:"eUsername",type:"String",label:""},eDatetime:{name:"eDatetime",type:"Datetime",label:""},userId:{name:"userId",type:"String",label:""},enterpriseNo:{name:"enterpriseNo",type:"String",label:""},enterpriseName:{name:"enterpriseName",type:"String",label:""},version:{name:"version",type:"long",label:""}};
		options.isTree = false;
		options.parentRelation = 'fParent';
		options.nodeKindRelation = 'nodeKind';
		options.nodeLevelRelation = 'nodeLevel';
		options.pathRelation = '';
		options.master = {"data":"","relation":""};
		options.directDeleteMode = true;
		options.limit = 15;
		options.orderBy = 'FileItem.itemNo DESC';

		options.onIndexChanging = null;
		options.onIndexChanged = Model.dataMasterIndexChanged;
		options.onBeforeNew = Model.dataMasterBeforeNew;
		options.onAfterNew = Model.dataMasterAfterNew;
		options.onBeforeDelete = Model.dataMasterBeforeDelete;
		options.onAfterDelete = Model.dataMasterAfterDelete;
		options.onValueChanged = Model.dataMasterValueChanged;
		options.onDataChanged = Model.dataMasterDataChanged;
		options.onBeforeSave = Model.dataMasterBeforeSave;
		options.onAfterSave = Model.dataMasterAfterSave;
		options.onNewCreateParam = Model.dataMasterNewCreateParam;
		
		Model.dataMaster = new BizData(options);
//		Model.objects.dataMaster = Model.dataMaster;
		//监视对象中的所有变动
		Model.dataMaster.deregRows = $scope.$watch('Model.dataMaster.rows',Model.dataMaster.watchRows,true);//true代表深度监视，包括对象的属性，而不是简单的一个值

		
		Model.dataMaster.refreshData();
		
		$scope.tabpanel = 'list';
		
	    return Model;
	}	
	
